<?php include("header.php");
include("functions.php");
if($_SESSION['user_level'] != 1 OR (!$_SESSION['signed_in']))
{
header("location: redirect.php");
}
else
 {
  if ($_SERVER['REQUEST_METHOD'] != 'POST')
  {
if ($handle = opendir("../lang")) {
echo "<table><tr><td>";
$language = get_value_of('$def_language');
echo '<br /><form name="myForm" method="post" action=""><b>	&nbsp; &nbsp;Choose default forum language: </b><br /></b>&nbsp; &nbsp;'; 
$choose = '<select name="sel_lang">';
    while (false !== ($file = readdir($handle))) {
	$selected = "";
	if ($file !="." AND $file !="index.html" AND $file !="..")
        {$lang = $lang.$file;
$sel_lang = str_replace(".php","",$file);
if (trim($sel_lang) == trim($language)) {$selected="selected";}
$choose.='<option  '.$selected.' value="' . $sel_lang . '">' . $sel_lang . '&nbsp;</option>';
		}
    }
	echo $choose;
	echo '</select><br /><br />';
    while ($file = readdir($handle)) {
        echo "$file<br /></td></tr>";
    }
    closedir($handle); 
 }
$lang = str_replace(".php"," | ",$lang);


if ($handle = opendir("../style")) {
echo "<tr><td>	&nbsp; &nbsp;<b>Choose default forum style:</b><br>&nbsp; &nbsp;";
$mystyle = get_value_of('$default_style');
$chooses = '<select name="style">';
    while (false !== ($file = readdir($handle))) {
	$selected = "";
	if ($file !="." AND $file !="index.html" AND $file !=".." AND strstr($file,".png")==false AND strstr($file,".css")==false AND strstr($file,".js")==false)
        {$lang = $lang.$file;
$style = str_replace(".php","",$file);		
if (trim($style) == trim($mystyle)) {$selected="selected";}
$chooses.='<option  '.$selected.' value="' . $style . '">' . $style . '&nbsp;</option>';
		}
    }
	echo $chooses;
	echo '</select><br /><br />';
	echo '<input type="submit" class="menuButtons" value="Submit" />
 </input>';
    while ($file = readdir($handle)) {
        echo "$file<br />";
    }
    closedir($handle); 
 }
$lang = str_replace(".php"," | ",$lang);

echo "</form></td></tr></table>";


      $pageTitle = "AdminCP";
      $pageContents = ob_get_contents();
      ob_end_clean();
      echo str_replace('<!--TITLE-->', $pageTitle, $pageContents);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if ($_POST['sel_lang']!="")
{write_value_of('$def_language', "$def_language", $_POST['sel_lang']);}

if ($_POST['style']!="")
{write_value_of('$default_style', "$default_style", $_POST['style']);}
$pageTitle = "AdminCP";
$pageContents = ob_get_contents ();
ob_end_clean ();
echo str_replace ('<!--TITLE-->', $pageTitle, $pageContents);  
echo "<div align='center'>Configuration successfully updated!<br><br><a href = 'style.php'>Back to previous page</a></div>";	
}
}
?>